<?php
function getFace($v){
	if ($v) {
		return $v;
	}else{
		return STATICS.'/image/avtar.png';
	}
}

function trainStrtoArr($tarinStr){	
	$tarinStr = substr($tarinStr,1);
    $tarinStr = substr($tarinStr,0,strlen($tarinStr)-1);
    $trainArr = explode('-', $tarinStr);
    return $trainArr;
}

function n2br($str){
	if ($str!='') {
		return str_replace("\n","<br />",$str);
	}	
}

//发邮件
function think_send_mail($email, $name, $title, $content) {
    Vendor('PHPMailer.PHPMailerAutoload'); 
    $mail = new PHPMailer(); //实例化
    $mail->IsSMTP(); // 启用SMTP 
    $mail->SMTPDebug = 1; // 关闭SMTP调试功能
    $mail->Host = C('SMTP_HOST'); //smtp服务器的名称
    $mail->Port = 465;
    $mail->SMTPSecure = "ssl"; 
    $mail->SMTPAuth = true; //启用smtp认证
    $mail->Username = C('SMTP_USER'); //你的邮箱名
    $mail->Password = C('SMTP_PASS'); //邮箱密码
    $mail->From = C('FROM_EMAIL'); //发件人地址（也就是你的邮箱地址）
    $mail->FromName = C('FROM_NAME'); //发件人姓名
    $mail->AddAddress($email, $name); //添加收件人
    $mail->WordWrap = 50; //设置每行字符长度
    $mail->IsHTML(true); // 是否HTML格式邮件
    $mail->CharSet = "utf-8"; //设置邮件编码
    $mail->Subject = $title; //主题
    $mail->Body = $content; //内容
    $mail->AltBody = ""; //正文不支持HTML的备用显示
    return $mail->Send();
}

?>